{{ 'sticky-navbar-new.css' | asset_url | stylesheet_tag }}
{%- liquid
  assign show_entry = false
  assign show_tab = false
  for block in section.blocks
    if forloop.first == true
      assign firstType = block.type
    endif
  endfor

  assign sales_channel_blocks = section.blocks | where: 'type', 'sales_channel'
-%}
<nav class="as-navbar-wrapper navbar-wrapper" id="sticky-navbar">
  <div class="container navbar-container">
    <div class="d-flex align-items-center navbar-content">
      <div class="product-sticky long-width">
        {% for block in sales_channel_blocks %}
          <div class="block-container">
            {% liquid
              case block.settings.button_color
                when 'light'
                  assign btn_style = 'btn-light'
                when 'dark'
                  assign btn_style = 'btn-dark'
                when 'accent1'
                  assign btn_style = 'btn-primary'
              endcase
            %}
            {% if block.settings.channel_link != blank %}
              <a
                class="btn {{ btn_style }} flex-nowrap btn-sm"
                href="{{ block.settings.channel_link }}"
                target="_blank"
              >
                {{ block.settings.button_label }}
              </a>
            {%- else -%}
              <div class="btn {{ btn_style }} flex-nowrap disabled cursor-default btn-sm">
                {{ block.settings.button_label }}
              </div>
            {%- endif -%}
          </div>
        {% endfor %}
      </div>
    </div>
  </div>
</nav>

{% schema %}
{
  "name": "Sticky navbar new",
  "class": "sticky-navbar as-sticky-navbar sticky-navbar-customized position-sticky",
  "tag": "section",
  "settings": [],
  "blocks": [
    {
      "type": "sales_channel",
      "name": "Sales channel",
      "settings": [
        {
          "type": "text",
          "id": "button_label",
          "label": "Button label",
          "default": "Buy now"
        },
        {
          "type": "select",
          "id": "button_color",
          "label": "Button color",
          "options": [
            {
              "value": "accent1",
              "label": "Accent 1"
            },
            {
              "value": "light",
              "label": "White"
            },
            {
              "value": "dark",
              "label": "Black"
            }
          ],
          "default": "accent1"
        },
        {
          "type": "url",
          "id": "channel_link",
          "label": "Channel link"
        }
      ]
    }
  ],
  "presets": [
    {
      "name": "Sticky navbar new"
    }
  ]
}
{% endschema %}
